<!DOCTYPE html>
<html>
<style>
    p {
        height: 80px;
        line-height: 80px;
        font-size: 16px;
    }
</style>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id='app'>
        <div v-for='(item,index) in list' v-color:brown:yellow.four='index'>
            <p>{{item.a}}</p>
            <!-- <p>{{item.b}}</p>
            <p>{{item.c}}</p>
            <p>{{item.d}}</p> -->
        </div>

    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                list: [{ a: '哈哈哈' }, { a: '呀呀呀' }, { a: '啦啦啦' }, { a: '哒哒哒' }]
            },
            directives: {
                color: {
                    bind(el, binding) {
                        console.log(binding);
                        console.log(el);

                        let colors = binding.arg.split(":")
                        console.log(colors);

                        binding.value = Number(binding.value)

                        if (binding.modifiers.four) {
                            if (binding.value % 2 == 0) {
                                el.style.backgroundColor = colors[0]
                            } else {
                                el.style.backgroundColor = colors[1]
                            }
                        }
                    },
                    inserted(el, binding) {
                    },
                    update(el, bindding) { }
                }
            }
        })
    </script>
</body>

</html>